﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
    	<title>查看Job定义</title>
<jsp:include page="common/header.jsp"/>
		<script type="text/javascript">
			function createTabBar(htmlDiv1) {
				var tabbar = new dhtmlXTabBar(htmlDiv1, "top");
				tabbar.setSkin('dhx_skyblue');
				tabbar.setImagePath("static/dhtmlx/imgs/");
				<c:set var="tabIndex" value="${0}"/>
				<c:if test="${conf.parameterSize>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "参数信息", "100px");tabbar.setContent("a${tabIndex}", "parameter");</c:if>
				<c:if test="${fn:length(parentConfs)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "被以下任务引用", "100px");tabbar.setContent("a${tabIndex}", "refer");</c:if>
				<c:if test="${fn:length(fireConfs)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "可触发以下任务", "100px");tabbar.setContent("a${tabIndex}", "refer-dependency");</c:if>
				<c:if test="${fn:length(triggers)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "调度信息", "100px");tabbar.setContent("a${tabIndex}", "scheduler");</c:if>
				<c:if test="${fn:length(dependencies)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "可被以下任务触发", "100px");tabbar.setContent("a${tabIndex}", "dependency");</c:if>
				<c:if test="${fn:length(jobs)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "时间曲线", "100px");tabbar.setContent("a${tabIndex}", "ChartDiv");</c:if>
				<c:if test="${fn:length(jobs)>0}"><c:set var="tabIndex" value="${tabIndex+1}"/>tabbar.addTab("a${tabIndex}", "Job信息", "100px");tabbar.setContent("a${tabIndex}", "jobs");</c:if>
				tabbar.enableAutoSize(true, true);
			<c:choose>
				<c:when test="${tabIndex>0}">tabbar.setTabActive("a${tabIndex}");</c:when>
				<c:otherwise>$("#TabBarDiv").hide();</c:otherwise>
			</c:choose>
			}
			
<c:if test="${fn:length(jobs)>0}">
			function createChart(htmlDiv1) {
				var data = [];
<c:forEach var="job" items="${jobs}" varStatus="vs"><c:if test="${ss:isFinished(job.status)}">
				data.push({ idx:'${ss:getJobLabel(job, vs.index)}', identifier:'${job.identifier.stringIdentifier}', para:'${job.parameters}', wait:${(job.launchTime - job.submitTime)/1000}, run:${(job.finishTime - job.launchTime)/1000}});
</c:if></c:forEach>
				data.reverse();

				var barChart = new dhtmlXChart({
					view: "line",
					container: htmlDiv1,
					value: "#run#",
					item: {
						borderColor: "#000000",
						color: "#ffffff",
						borderWidth: 1,
						radius: 3
					},
					line: {
						color: "#3399ff",
						width: 3
					},
					tooltip: {
						template: "#identifier#<br>Wait Time:#wait#, Run Time:#run#<br>#para#"
					},
					xAxis: {
						title: "Index",
						template: "#idx#",
						lines: true
					},
					yAxis: {
						title: "Time (sec)",
					},
					legend: {
						layout: "x",
						width: 75,
						align: "right",
						valign: "middle",
						marker: {
							type: "round",
							width: 15
						},
						values: [{
							text: "Run Time",
							color: "#3399ff"
						}, {
							text: "Wait Time",
							color: "#66cc00"
						}]
					}
				});
				barChart.addSeries({
					value: "#wait#",
					item: {
						borderColor: "#66cc00",
						color: "#ffffff",
						borderWidth: 1,
						radius: 3
					},
					line: {
						color: "#66cc00",
						width: 3
					}
				});
				barChart.parse(data, "json");
			}
</c:if>

			$(function(){
				createTabBar('TabBarDiv');
				<c:if test="${fn:length(jobs)>0}">createChart('ChartDiv');</c:if>
			});
		</script>
	</head>
	<body>
<jsp:include page="common/body-header.jsp"/>
<jsp:include page="fragment/job-conf-view-base.jsp"/>
<jsp:include page="fragment/job-conf-view-action.jsp"/>
		<hr>
		<div id="TabBarDiv" style="width:100%; height:90px;"></div>
<c:if test="${fn:length(jobs)>0}">
		<div id="ChartDiv" style="width:900px;height:300px;border:1px solid #A4BED4;"></div>
</c:if>
<c:if test="${conf.parameterSize>0}">
		<table id="parameter">
			<tr valign="top">
				<td align="right" width="100">参数：</td>
				<td><ol><c:forEach var="p" items="${conf.parameters}">
					<li>参数名：<b>${p.name}</b>，预设值：${ss:getParameterDefineTypeName(p.type)}<c:if test="${p.type!='none'}">，内容：${p.value}</c:if></li>
				</c:forEach></ol></td>
			</tr>
		</table>
</c:if>
<jsp:include page="fragment/job-conf-view-refer.jsp"/>
<jsp:include page="fragment/job-conf-view-refer-dependency.jsp"/>
<jsp:include page="fragment/job-conf-view-scheduler.jsp"/>
<jsp:include page="fragment/job-conf-view-dependency.jsp"/>
<jsp:include page="fragment/job-conf-view-jobs.jsp"/>
<jsp:include page="common/body-footer.jsp"/>
	</body>
</html>
